package com.utility.util;


import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;

/**
 * @author: hw
 * @date: 2020/8/28 14:17
 */
public class IdCreateBy extends DefaultIdentifierGenerator implements Cloneable {

    private static IdCreateBy idCreateBy ;

    static {
        idCreateBy = new IdCreateBy();
    }
    /**
     * 获取主键id
     * @return
     */
    protected Long createById(){
       return super.nextId(3);
    }

    @Override
    protected Object clone()
    {
        try
        {
            return super.clone();
        } catch (CloneNotSupportedException e)
        {
            e.printStackTrace();
        }
        return null;
    }


    protected static IdCreateBy idCreateBy(){
        return  ((IdCreateBy)idCreateBy.clone());
    }

    /**
     *  获取主键id
     * @return
     */
    public static Long getById(){
        return idCreateBy().createById();
    }

    public static void main(String[] args) {

        for(int i = 0 ; i<=8;i++){
            System.out.println(getById());
        }


    }

}
